/**
 * 弯弯工作组
 */
function friendsyearbookInit(url,json,userId) {
	$(".tjnj").wjDropList({source:eval(json),dropDownId:"tdnj_btn",value:"个人",userId:userId});
	$("#tjnj_btn_personal").click(function(){
		$("#drop_down_show").val("个人");
		$("#drop_down_hide").val(userId);
	});
	$("#showUserDynamicInfo").load(url+"public_view/getYearBookInfo/"+userId);
	$("#character").wjValidate({tip:"人物",error:"请填写年鉴里的人",button:$("#yearbooksubmit")});
	$("#address").wjValidate({tip:"在哪里",error:"请填写年鉴地点",button:$("#yearbooksubmit")});
	$("#content").wjValidate({tip:"发生了什么",error:"请填写年鉴的经过",button:$("#yearbooksubmit")});
	$("#inspiron").wjValidate({tip:"事件意义",error:"请填写年鉴的印象",button:$("#yearbooksubmit")});
	$("#yearbookFile").change(function(){
		$('#submitYearbookForm').ajaxSubmit({
			url : url+"sczp/imageUp/file",  
			dataType : "json",  
			success : function(data){
				if(parseInt(data.type)==1){
					$("#yearbookImgCon").before("<img src='"+data.path+"' class='imageShow'  width='109px' height='109px'/>");  
				}else{	
					$("#dialogDiv").wjDialog({url:url,content:data.msg});
				}
			},  
			error:function(){  
				$("#dialogDiv").wjDialog({url:url,content:"系统繁忙请稍后再试"});
			}   
		}); 
	});
	$("#yearbooksubmit").click(function(){
         if($(".error").length!=0){
			$("#dialogDiv").wjDialog({url:url,content:"请将年鉴信息填写完整"});
			return;
         }
         var imgStr="";
         $("#submitYearbookForm .imageShow").each(function(e){imgStr+=$(this).attr("src")+","});
         imgStr=imgStr.substr(0,imgStr.length-1);
         $.post(url + "user/userDynamicAdd/yearbook", {
				"yearbookYearDate" : $("#yearbookYearDate").val(),//年鉴月份
				"character" : $("#character").val(),//人物
				"yearbookRelegation" : $("#yearbookRelegation").val(),
				"yearbookType" : $("#yearbookType").val(),
				"yearbookYearDate" : $("#yearbookYearDate").val(),
				"yearbookMDDate" : $("#yearbookMonthDate").val()+"月"+$("#yearbookDayDate").val()+"日",
				"content" : $("#content").val(),
				"inspiron" : $("#inspiron").val(),
				"address":$("#address").val(),
				"yearbookRelegation":$("#drop_down_hide").val(),
				"yearbookType":$("#drop_down_show").val()=='个人'?1:0,
				"imageUrl" : imgStr,
				"userId":userId
			}, function(data) {		
				$("#dialogDiv").wjDialog({url:url,content:data.msg});
				$("#user_yearbook").click();//年鉴
			}, "json");
	});
}
